package com.xjscrm.console.service.customer.chat;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xjscrm.common.entity.WwGroupTags;
import com.xjscrm.common.entity.WwTags;
import com.xjscrm.console.chat.frame.dto.ChatSessionDTO;
import com.xjscrm.console.chat.frame.recv.RPullSessionMsg;
import com.xjscrm.console.chat.frame.recv.RPullTalkSessionMsg;
import com.xjscrm.console.dto.chat.ChatTalkSessionQueryDTO;
import com.xjscrm.console.entity.ChatTalkSession;
import com.xjscrm.console.vo.LoginVO;
import com.xjscrm.console.vo.chat.ChatTalkSessionDeviceVO;

import java.util.List;
import java.util.function.Consumer;

/**
 * 聊天回话(ChatTalkSession)表服务接口
 *
 * @author szl
 * @since 2024-03-12 13:35:17
 */
public interface ChatTalkSessionService {

    List<ChatTalkSession> loadByDeviceUniqueId(RPullTalkSessionMsg content);

    ChatSessionDTO get(ChatTalkSessionQueryDTO query);

    void add(ChatTalkSession talkSession);

    void update(ChatTalkSession newTalkSession);

    void delete(Long merId, Long id);

    ChatTalkSession getById(Long merId, Long talkSessionId);

    List<ChatTalkSessionDeviceVO> listDevice(LoginVO login);

    Object search(LoginVO login, ChatTalkSessionQueryDTO query);

    Boolean removeShield(LoginVO login, List<Long> ids);

    Boolean syncShield(LoginVO login, List<Long> ids, List<Long> deviceUniqueIds);

    @Deprecated
    ChatTalkSession getByConversationIdAndDeviceId(Long merId, String conversationId, String deviceId);

    List<ChatTalkSession> getByIds(Long merId, List<Long> newTalkSessionIds);

    Page<ChatTalkSession> page(Long merId, RPullSessionMsg content);

    ChatTalkSession getByConvIdAndDeviceUniqueId(Long merId, Long deviceUniqueId, String conversationId);

    void fillTag(ChatTalkSession talkSession, Consumer<WwTags> callback, Consumer<WwGroupTags> ca);

    void fillConversationName(ChatTalkSession talkSession, ChatSessionDTO talkSessionMsg);

    List<ChatTalkSession> listByConversationIds(Long merId, Long deviceUniqueId, List<String> conversationIds);

    boolean checkConversationName(Long merId, Long deviceUniqueId, String conversationName);

    List<Long> listOrderSessionIds(Long merId, Long staffId, Long deviceUniqueId);

    ChatSessionDTO convert(ChatTalkSession talkSession);

    void fetchAndPushOrderSession(Long merId, Long staffId, Long deviceUniqueId, Long... excludeSessionId);

    List<ChatTalkSession> listByIds(Long merId, List<Long> talkSessionIds);

    // 分割

    /**
     * 添加聊天过期延迟任务
     */
    void addChatRecvDelayTask(Long merId, Long staffId, ChatTalkSession talkSession);

    void delChatRecvDelayTask(Long merId, Long staffId, ChatTalkSession talkSession);

    void addChatSendDelayTask(Long merId, Long staffId, ChatTalkSession talkSession);

    void delChatSendDelayTask(Long merId, Long staffId, ChatTalkSession talkSession);

    void addChatCleanDelayTask(Long merId, Long staffId, ChatTalkSession talkSession);

    void delChatCleanDelayTask(Long merId, Long staffId, ChatTalkSession talkSession);

    // 结束
    void endTalkSession(Long merId, Long staffId, Long talkSessionId, Boolean auto);

    //
    void cleanTalkSession(Long merId, Long staffId, Long talkSessionId);

    //
    void markTalkSessionTimeout(Long merId, Long staffId, Long talkSessionId);
}

